import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';

import 'package:get/get.dart';
import 'package:myapp/app/theme/app_color.dart';
import 'package:myapp/app/theme/resource/images.dart';

import '../controllers/login_controller.dart';

class LoginView extends GetView<LoginController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        width: Get.size.width,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Image.asset(ImageKeys.top_bg, fit: BoxFit.fitWidth,width: double.infinity,),
            Padding(
              padding: EdgeInsets.only(left: 20, right: 20),
              child: TextField(
                decoration: InputDecoration(
                  icon: Image.asset(ImageKeys.icon_account),
                  hintText: "请输入",
                  labelText: "用户名：",
                ),
                keyboardType: TextInputType.emailAddress,
                maxLength: 20,
                onChanged: (s) {
                  controller.userName.value = s;
                },
              ),
            ),
            Padding(
              padding: EdgeInsets.only(left: 20, right: 20),
              child: TextField(
                decoration: InputDecoration(
                  icon: Image.asset(ImageKeys.icon_pwd),
                  hintText: "请输入",
                  labelText: "密码：",
                ),
                keyboardType: TextInputType.visiblePassword,
                maxLength: 8,
                obscureText: true,
                onChanged: (s) {
                  controller.password.value = s;
                },
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 30),
              child: ElevatedButton(
                style: ButtonStyle(
                    padding: MaterialStateProperty.resolveWith(
                        (states) => EdgeInsets.only(left: 60, right: 60))),
                child: Text("登录"),
                onPressed: () => controller.pressLogin(),
              ),
            )
          ],
        ),
      ),
    );
  }
}
